﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using IChessEngine;

namespace ChessEngine.Gaming
{
    public class ChsGamePosition : IChsGamePosition
    {
        private IChsPosition position;
        private Guid id;
        public Guid Id
        {
            get { return id; }
        }
        public ChsGamePosition()
        {
            id = Guid.NewGuid();
            position = ChsFactory.CreatePosition();
        }
        public ChsGamePosition(IChsGamePosition _position)
        {
            id = Guid.NewGuid();
            position = ChsFactory.CreatePosition((IChsPosition)_position);
        }
        public ChsGamePosition(IChsPosition _position)
        {
            id = Guid.NewGuid();
            position = ChsFactory.CreatePosition(_position);
        }
        public ChsGamePosition(Guid _id, IChsPosition _position)
        {
            id = _id;
            position = ChsFactory.CreatePosition(_position);
        }
        public bool AllyKingCheck
        {
            get { return position.AllyKingCheck; }
        }

        public bool EnemyKingCheck
        {
            get { return position.EnemyKingCheck; }
        }

        public EChsPieceColor ColorToMove
        {
            get { return position.ColorToMove; }
        }

        public bool WhiteCastleQueenSide
        {
            get { return position.WhiteCastleQueenSide; }
        }

        public bool WhiteCastleKingSide
        {
            get { return position.WhiteCastleKingSide; }
        }

        public bool BlackCastleQueenSide
        {
            get { return position.BlackCastleQueenSide; }
        }

        public bool BlackCastleKingSide
        {
            get { return position.BlackCastleKingSide; }
        }
        public bool PermanentWhiteCastleQueenSide
        {
            get { return position.PermanentWhiteCastleQueenSide; }
        }

        public bool PermanentWhiteCastleKingSide
        {
            get { return position.PermanentWhiteCastleKingSide; }
        }

        public bool PermanentBlackCastleQueenSide
        {
            get { return position.PermanentBlackCastleQueenSide; }
        }

        public bool PermanentBlackCastleKingSide
        {
            get { return position.PermanentBlackCastleKingSide; }
        }
        public IChsBoard GetBoard()
        {
            return position.GetBoard();
        }

        public IChsPosition Execute(IChsMovement movement)
        {
            return position.Execute(movement);
        }

        public IChsPiece GetPieceAt(IChsSquare square)
        {
            return position.GetPieceAt(square);
        }

        public IChsPiece GetPieceAt(int x, int y)
        {
            return position.GetPieceAt(x,y);
        }

        public bool HasAllyPiece(IChsSquare source)
        {
            return position.HasAllyPiece(source);
        }

        public bool HasPiece(IChsSquare target)
        {
            return position.HasPiece(target);
        }

        public bool HasPiece(int x, int y)
        {
            return position.HasPiece(x,y);
        }

        public bool HasEnemyPiece(IChsSquare square)
        {
            return position.HasEnemyPiece(square);
        }

        public bool HasEnemyPiece(int x, int y)
        {
            return position.HasEnemyPiece(x,y);
        }

        public bool IsPromotingMovement(IChsSquare source, IChsSquare target)
        {
            return position.IsPromotingMovement(source, target);
        }
    }
}
